
import requestDP from "@/utils/request-dp";
export function getServerList(params) {
  return requestDP({
    url: `/api/v1/servers`,
    method: 'get',
    params
  })
}

export function createServer( body) {
  return requestDP({
    url: `/api/v1/servers`,
    method: 'post',
    data: body
  })
}


export function updateServer(id, body) {
  return requestDP({
    url: `/api/v1/servers/${id}`,
    method: 'put',
    data: body
  })
}

export function deleteServer(id) {
  return requestDP({
    url: `/api/v1/servers/${id}`,
    method: 'delete',
  })
}


// clusters 相关接口
export function getClustersList(params) {
  return requestDP({
    url: `/api/v1/clusters`,
    method: 'get',
    params
  });
}

export function createCluster(body) {
  return requestDP({
    url: `/api/v1/clusters`,
    method: 'post',
    data: body
  });
}

export function updateCluster(id, body) {
  return requestDP({
    url: `/api/v1/clusters/${id}`,
    method: 'put',
    data: body
  });
}

export function deleteCluster(id) {
  return requestDP({
    url: `/api/v1/clusters/${id}`,
    method: 'delete'
  });
}

// databases 相关接口
export function getDatabasesList(params) {
  return requestDP({
    url: `/api/v1/databases`,
    method: 'get',
    params
  });
}

export function createDatabase(body) {
  return requestDP({
    url: `/api/v1/databases`,
    method: 'post',
    data: body
  });
}

export function updateDatabase(id, body) {
  return requestDP({
    url: `/api/v1/databases/${id}`,
    method: 'put',
    data: body
  });
}

export function deleteDatabase(id) {
  return requestDP({
    url: `/api/v1/databases/${id}`,
    method: 'delete'
  });
}

// instances 相关接口
export function getInstancesList(params) {
  return requestDP({
    url: `/api/v1/instances`,
    method: 'get',
    params
  });
}

export function createInstance(body) {
  return requestDP({
    url: `/api/v1/instances`,
    method: 'post',
    data: body
  });
}

export function updateInstance(id, body) {
  return requestDP({
    url: `/api/v1/instances/${id}`,
    method: 'put',
    data: body
  });
}

export function deleteInstance(id) {
  return requestDP({
    url: `/api/v1/instances/${id}`,
    method: 'delete'
  });
}

// accounts 相关接口
export function getAccountsList(params) {
  return requestDP({
    url: `/api/v1/accounts`,
    method: 'get',
    params
  });
}

export function createAccount(body) {
  return requestDP({
    url: `/api/v1/accounts`,
    method: 'post',
    data: body
  });
}

export function updateAccount(id, body) {
  return requestDP({
    url: `/api/v1/accounts/${id}`,
    method: 'put',
    data: body
  });
}

export function deleteAccount(id) {
  return requestDP({
    url: `/api/v1/accounts/${id}`,
    method: 'delete'
  });
}
